package com.prac.common.result;

import java.io.Serializable;

import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = false)
public class DataResult<T extends Serializable> extends Result {

    private T data;

    public DataResult(T data) {
        this(0, data);
    }

    public DataResult(int errorCode, T data) {
        if (null == data) {
            super.setCode(errorCode);
        } else {
            this.data = data;
        }
    }

    public DataResult(int errorCode, String message, T data) {
        super(errorCode, message);
        if (null == data) {
            super.setCode(errorCode);
        } else {
            this.data = data;
        }
    }
}
